package com.bckj.fastboot.core.extra.relational;

import com.bckj.fastboot.core.lang.model.PageResult;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.jdbc.core.simple.JdbcClient;

import java.util.List;

/**
 * RelaRepository
 *
 * @author wfc
 * @date 2025/11/11 16:31
 **/
@NoRepositoryBean
public interface IRelationalRepository<Entity, ID> {

    boolean save(Entity entity);

    boolean saveBatch(Iterable<Entity> entities);

    boolean updateById(Entity entity);

    boolean updateBatchById(Iterable<Entity> entities);

    int update(Query query, Update update);

    boolean removeById(ID id);

    boolean remove(Query query);

    Entity findById(ID id);

    <T> T findById(ID id, Class<T> entityClass);

    List<Entity> find(Query query);

    <T> List<T> find(Query query, Class<T> entityClass);

    long count(Query query);

    PageResult<Entity> page(Pageable pageable, Query query);

    PageResult<Entity> page(Pageable pageable, Query query, Class<Entity> entityClass);

    JdbcClient.StatementSpec sql(String sql);

    JdbcClient.StatementSpec execute(Query query);

    JdbcClient.StatementSpec execute(Query query, Update update);
}
